import request from '@/utils/request'

export default {
  // 获取用户列表
  getUserList(page, limit, keyword) {
    return request({
      url: `/aclservice/user/list`,
      method: 'get',
      params: { page, limit, keyword }
    })
  },

  getAllRoles() {
    return request({
      url: `/aclservice/role/list`,
      method: 'get'
    })
  },

  // 根据ID获取用户
  getUserById(id) {
    return request({
      url: `/aclservice/user/${id}`,
      method: 'get'
    })
  },

  // 新增用户
  addUser(user) {
    return request({
      url: '/aclservice/user',
      method: 'post',
      data: user
    })
  },

  // 修改用户
  updateUser(user) {
    return request({
      url: '/aclservice/user',
      method: 'put',
      data: user
    })
  },

  // 删除用户
  deleteUser(id) {
    return request({
      url: `/aclservice/user/${id}`,
      method: 'delete'
    })
  },

  // 批量删除用户
  batchRemoveUser(idList) {
    return request({
      url: '/aclservice/user/batch',
      method: 'delete',
      data: idList
    })
  },

  // 为用户分配角色
  assignRoles(userId, roleIds) {
    return request({
      url: `/aclservice/user/assign/${userId}`,
      method: 'post',
      data: roleIds
    })
  },

  // 获取用户的角色ID列表
  getRoleIdsByUserId(userId) {
    return request({
      url: `/aclservice/user/roles/${userId}`,
      method: 'get'
    })
  },

  //检查用户名是否存在
  checkUsername(username) {
    return request({
      url: `/aclservice/user/checkUsername/${username}`,
      method: 'get'
    })
  },
} 